<?php 
 // nusoap.php еͧäǡѺ hello.php 
	require_once('lib/nusoap.php');
//ҧѧ蹷ͧԡ ¿ѧ蹹 hello 
    function getdata(){
		 include("connect/connect.php");
		mysql_select_db("military",$c);
		mysql_query("set names utf8");
        $sql="select min(recid) as minpk,max(recid) as maxpk from victim where senddscc <> 1";
		$rs=mysql_query($sql);
		$result = mysql_fetch_array($rs);
		$minpk=$result["minpk"];
		$maxpk=$result["maxpk"];
		$sql = "select recid,code_ps,code_acc,prename,fname,sname,code_id,sts  from victim  where recid between '$minpk' and '$maxpk'";
		//echo $sql;
		$rs=mysql_query($sql);
		$str_return="";	//$str_return="code_acc,date_acc,time_acc,plcid_acc,type_acc1,type_acc2,type_acc3,cause,point_xy,point_x,point_y,trans,weapon1,weapon2,weapon3,weapon4,weapon5,weapon6,weapon7,weapon8,num_loss,num_dth,num_wnd,commt;";
		while ($result = mysql_fetch_array($rs)){//ǹٻҧ text 
			$str_return=$str_return.$result["recid"].",".$result["code_ps"].",".$result["code_acc"].",".$result["prename"].",".$result["fname"].",".$result["sname"].",".$result["code_id"].",".$result["sts"].";";
		}
		//Ѻاʶҹä촷觢
		$tempY=date("Y");
		if($tempY<"2500"){
			$tempY=(int)$tempY+543;
		}
		$datetime_send= $tempY.date("-m-d-H:i");
		$sql="update victim set senddscc=1,datetime_send='$datetime_send' where recid between '$minpk' and '$maxpk'";
		//echo "<br>".$sql;
		$rs=mysql_query($sql);
		// end Ѻاʶҹä촷觢
		return $str_return;
	}

	function getMilitaryVictim($name){ 
		return getdata();
	} 

 	$ws_server = new soap_server; // ҧ instance ͧ Soap-Server 
	//*** ¡ѧ configureWSDL ͧ Soap-Server з WSDL File  
$ws_server->configureWSDL('getMilitaryVictimWSDL', 'http://localhost/dsccmis/datasource_webservice/');
 
//ӡŧ¹ѧ蹷ͧԡ
$ws_server->register('getMilitaryVictim',array('name'=>'xsd:string'),array('militaryvictim'=>'xsd:string'),'http://localhost/dsccmis/datasource_webservice/','http://localhost/dsccmis/datasource_webservice','rpc','encoded','send MilitaryVictim');

// Use the request try to invoke the service 
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $ws_server->service($HTTP_RAW_POST_DATA); 
//echo getdata();

?> 
